<?php
	class Rights
	{
		public function getMaskItems($userid)
		{
			$roles = WebApp::app()->db->select(array('*'),array('maskassignment'),'user_id = '.$userid);
			$roles = $this->getRoles($roles);
			/*$roles = WebApp::app()->db->select(array('*'),array('maskassignment'),'user_id = '.$userid);
			$tmp  = array();
			$tmp2 = array();
			$roles = array(array_merge($roles,WebApp::app()->db->select(array('*'),array('maskitemchild'),'parent = "'.$r->itemname.'" and type = 2')));
			foreach($roles as $r){
				$tmp[] = WebApp::app()->db->select(array('*'),array('maskitemchild'),'parent = "'.$r->itemname.'" and type = ');
			}
			foreach($tmp as $t){
				foreach($t as $row){
					$tmp2[$row->child] = $row->child;
				}
			}
			return $tmp2;*/
		}
		
		private function getRoles($startRoles)
		{
			$tmp = array();
			foreach($startRoles as $rol)
			{
				$tmp = array_merge($tmp, WebApp::app()->db->select(array('*'),array('maskitemchild'),''));
			}
			WebApp::app()->db->select(array('*'),array('maskitemchild'));
		}
	}
?>